const { Sequelize } = require('sequelize');
const configFn = require('./config/config.default.js');
const appConfig = configFn({ name: 'lingxi-system' });

// 创建数据库连接
const sequelize = new Sequelize(appConfig.sequelize.database, appConfig.sequelize.username, appConfig.sequelize.password, {
  host: appConfig.sequelize.host,
  port: appConfig.sequelize.port,
  dialect: appConfig.sequelize.dialect,
  timezone: appConfig.sequelize.timezone,
  define: appConfig.sequelize.define,
  logging: false, // 关闭SQL日志
});

async function checkBatch() {
  try {
    // 测试数据库连接
    await sequelize.authenticate();
    console.log('数据库连接成功');
    
    // 查询特定批次
    const batchId = 'batch_1763968563435_4r6i70dcf';
    const batches = await sequelize.query(
      'SELECT * FROM plugin_data_batches WHERE batch_id = ?', 
      { 
        type: sequelize.QueryTypes.SELECT,
        replacements: [batchId]
      }
    );
    
    console.log('批次信息:');
    console.log(JSON.stringify(batches, null, 2));
    
  } catch (error) {
    console.error('查询数据时出错:', error);
  } finally {
    await sequelize.close();
  }
}

checkBatch();